#include <cstring>
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

stack<int> num;
stack<int> op;

void calc()
{
    bool a, b;

    if (op.top() == 1)
    {
        if (num.size() < 2)
        {
            cout << "error" << endl;
            exit(0);
        }
        a = num.top();
        num.pop();
        b = num.top();
        num.pop();
        num.push(a || b);
    }
    else if (op.top() == 3)
    {
        a = num.top();
        num.pop();
        num.push(!a);
    }
    else
    {
        if (num.size() < 2)
        {
            cout << "error" << endl;
            exit(0);
        }
        a = num.top();
        num.pop();
        b = num.top();
        num.pop();
        num.push(a && b);
    }

    op.pop();
}

int main()
{
    string s;
    while (cin >> s)
    {
        if (s == "or")
        {
            while (!op.empty()) //优先级最小，所以之前的都要计算
            {
                calc();
            }
            op.push(1); // or优先级为1
        }
        else if (s == "and")
        {
            while (!op.empty() && op.top() >= 2) //优先级比and大的都要计算
            {
                calc();
            }
            op.push(2);
        }
        else if (s == "not")
        {
            op.push(3);
        }
        else if (s == "true")
        {
            num.push(1);
        }
        else if (s == "false")
        {
            num.push(0);
        }
        else
        {
            cout << "error" << endl;
            return 0;
        }
    }
    while (!op.empty())
    {
        calc();
    }
    if (num.size() != 1)
    {
        cout << "error" << endl;
        return 0;
    }
    else
    {
        if (num.top())
            cout << "true" << endl;
        else
            cout << "false" << endl;
    }
    system("pause");
    return 0;
}